module.exports = class extends think.Model {
    // get relation() {
    //     return {
    //         custom_params: {
    //             type: think.Model.HAS_MANY,
    //             key: 'id',
    //             fKey: 'pid',
    //             field: 'id,pid,hide_ids,custom_name,custom_desc,img,"F" as checked,"F" as hide',
    //             order: 'sort',
    //             where: {status: 0}
    //         }
    //     };
    // }

    getChildList(customid, l) {
        let list = [];
        let m = 0;
        for (let i = 0; i < l.length; i++) {
            if (l[i].custom_type === customid) {
                m++;
                let l_c = l[i];
                if (m == 1) {
                    l_c.checked = 'T';
                } else {
                    l_c.checked = 'F';
                }
                list.push(l_c);
            }
        }
        return list;
    }

    getList(customid, l) {
        let list = [];
        for (let i = 0; i < l.length; i++) {
            if (l[i].customid === customid) {
                let l_c = l[i];
                l_c.checked = 'F';
                list.push(l_c);
            }
        }
        if (list.length > 0) list[0].checked = 'T';
        return list;
    }

    getLists(custom_type, l) {
        let list = [];
        for (let i = 0; i < l.length; i++) {
            if (l[i].custom_type === custom_type) {
                let l_c = l[i];
                l_c.checked = 'F';
                list.push(l_c);
            }
        }
        return list;
    }
};
